package com.hc.conferencecheck.controller;

import com.alibaba.fastjson.JSONObject;
import com.hc.conferencecheck.entity.ResultMsg;
import com.hc.conferencecheck.service.MessageService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 用于短信相关的controller
 */
@RestController
@RequestMapping("/messageController")
public class MessageController {
    @Resource
    private MessageService messageServiceImpl;

    /**
     * 发送重置密码验证码接口
     *
     * @return
     */
    @RequestMapping("/sendEditPasswordVerificationCode")
    public ResultMsg sendEditPasswordVerificationCode(String param, HttpServletRequest request) {
        Map params = (Map) JSONObject.parseObject(param);
        ResultMsg resultMsg = messageServiceImpl.sendEditPasswordVerificationCode(params, request);
        return resultMsg;
    }

    /**
     * 发送注册验证码接口
     *
     * @return
     */
    @RequestMapping("/sendRegisterVerificationCode")
    public ResultMsg sendRegisterVerificationCode(String param, HttpServletRequest request) {
        Map params = (Map) JSONObject.parseObject(param);

        ResultMsg resultMsg = messageServiceImpl.sendRegisterVerificationCode(params, request);

        return resultMsg;
    }

    /**
     * 发送登录验证码接口
     *
     * @return
     */
    @RequestMapping("/sendLoginVerificationCode")
    public ResultMsg sendLoginVerificationCode(@RequestBody Map<String, Object> params, HttpServletRequest request) {
        ResultMsg resultMsg = messageServiceImpl.sendLoginVerificationCode(params, request);
        return resultMsg;
    }
}
